let picArr = [
	'https://img.alicdn.com/bao/uploaded/i3/2201315634/O1CN01pQEyKd1rUQ7hyDk0G_!!0-item_pic.jpg_600x600q90.jpg',
	'https://img.alicdn.com/bao/uploaded/i2/2204164889237/O1CN01UnNMSn2I6b4lpVhjU_!!0-item_pic.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i1/2204164889237/O1CN01oGFwmz2I6b3hFjrUp_!!2204164889237.png_600x600q90.jpg',
	'https://img.alicdn.com/i3/2204164889237/O1CN01ryYtrb2I6b3Kx2ug4_!!0-item_pic.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i3/2204164889237/O1CN01kXR8Mn2I6b30OFrna_!!2204164889237.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i2/2204164889237/O1CN01qEhOAY2I6b34E7Mom_!!2204164889237.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i4/2201315634/O1CN01nBl1Yb1rUQ7yCUJIE_!!2201315634.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i4/2201315634/O1CN01A82qK81rUQ7tSNmVW_!!2201315634.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i4/2201315634/O1CN018RPaXb1rUQ7vtaAiH_!!2201315634.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i2/2201315634/O1CN01CfXhYW1rUQ7qd2h5B_!!2201315634.jpg_600x600q90.jpg',
	'https://img.alicdn.com/bao/uploaded/i1/2003255563/O1CN01mRzn2r1qxttapgfqG_!!0-item_pic.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i2/2003255563/O1CN01DWXDbd1qxts0kM9QI_!!2003255563.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i1/2003255563/TB2jEcAbXooBKNjSZPhXXc2CXXa_!!2003255563.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i1/2003255563/TB2jEcAbXooBKNjSZPhXXc2CXXa_!!2003255563.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i4/2003255563/TB2xL59bf6TBKNjSZJiXXbKVFXa_!!2003255563.jpg_600x600q90.jpg',
	'https://img.alicdn.com/bao/uploaded/i2/2110132440/O1CN01uFbJyw1TtZ3QE3mWo_!!2110132440.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i3/2110132440/O1CN01ezjCSx1TtZ3OtGD1e_!!2110132440.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i2/2110132440/O1CN01IKUCzk1TtZ3Ju18nA_!!2110132440.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i4/2110132440/O1CN01zwdQG81TtZ3DN9egy_!!2110132440.jpg_600x600q90.jpg',
	'https://img.alicdn.com/i3/2110132440/O1CN012m4qcs1TtZ3RkCFXq_!!2110132440.jpg_600x600q90.jpg',
]

let picLen = picArr.length
let urlArr = getRandom(5, picLen)
urlArr = urlArr.map(item => picArr[item])
console.log(urlArr)
/**
 * 生成n个0-m的随机数，要求不能重复
 */
function getRandom(n, m) {
	if (n >= m) {
		throw new Error('n can not greater than m')
	}
	let arr = []
	let count = 0
	while (count < n) {
		let index = Math.floor(Math.random() * m)
		//判断index是否存在arr中，如果不存在加入arr
		if (arr.indexOf(index) == -1) {
			arr.push(index)
			count++
		}
	}
	return arr
}

console.log('>> ', getRandom(5, 18))
